package com.acme.bankapp.domine.account;

import com.acme.bankapp.exceptions.NoEnoughFundsException;

public class SavingAccount extends AbstractAccount {

    public SavingAccount(final int id, final double amount)
            throws IllegalArgumentException {
        super(id, amount);
        setType("SavingAccount");
    }

    public void withdraw(final double amount) throws NoEnoughFundsException {
        if (getBalance() >= amount) {
            setBalance(getBalance() - amount);
        } else {
            throw new NoEnoughFundsException("SavingAccount: "
                    + "Amount withdraw can not be negative");
        }
    }

    @Override
    public double maximumAmountToWithdraw() {
        return getBalance();
    }
}
